(function() {
  var Article, findAll, noop, save, verify, _;

  _ = require('underscore');

  Article = require('./mongoose_client').Article;

  noop = function() {};

  save = function(data, cbf) {
    cbf = cbf || noop;
    if (verify(data, cbf)) {
      return new Article(data).save(function(err) {
        return cbf(err);
      });
    }
  };

  findAll = function(cbf) {
    cbf = cbf || noop;
    return Article.find({}, cbf);
  };

  verify = function(data, cbf) {
    if (_.isObject(data)) {
      return true;
    } else {
      cbf(new Error('the save data is not a objcet'));
      return false;
    }
  };

  module.exports = {
    save: save,
    findAll: findAll
  };

}).call(this);
